package com.qf.config;

import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 自定义的任务
 */
@Component
public class DemoXxlJob {

    /**
     *     @Bean   XxlJobSpringExecutor：xxlJob执行对象
     *     public XxlJobSpringExecutor xxlJobExecutor() {
     *         logger.info(">>>>>>>>>>> xxl-job config init.");
     *         XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
     *         xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
     *         xxlJobSpringExecutor.setAppname(appname);
     *         xxlJobSpringExecutor.setAddress(address);
     *         xxlJobSpringExecutor.setIp(ip);
     *         xxlJobSpringExecutor.setPort(port);
     *         xxlJobSpringExecutor.setAccessToken(accessToken);
     *         xxlJobSpringExecutor.setLogPath(logPath);
     *         xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
     *         return xxlJobSpringExecutor;
     *     }
     *
     *
     *  @XxlJob("demoJobHandler")  ：
     *     XxlJobSpringExecutor 专门执行打有这个 @XxlJob 的方法
     *                        执行的任务也有任务的名称"demoJobHandler"
     *
     * @throws Exception
     */
    @XxlJob("demoJobHandler")
    public void demoJobHandler() throws Exception {
        //任务的执行内容
        System.out.println(new Date()+" : 任务开始执行 , thread = " + Thread.currentThread().getName());
    }
    @XxlJob("demoJobHandler1")
    public void demoJobHandler1() throws Exception {
        //任务的执行内容
        System.out.println(new Date()+" : 任务开始执行 , thread = " + Thread.currentThread().getName());
    }
}